import type { OpenRouterSharedSettings } from '..'

// https://openrouter.ai/api/v1/models
export type OpenRouterChatModelId = string

export type OpenRouterChatSettings = {
  /**
Modify the likelihood of specified tokens appearing in the completion.

Accepts a JSON object that maps tokens (specified by their token ID in
the GPT tokenizer) to an associated bias value from -100 to 100. You
can use this tokenizer tool to convert text to token IDs. Mathematically,
the bias is added to the logits generated by the model prior to sampling.
The exact effect will vary per model, but values between -1 and 1 should
decrease or increase likelihood of selection; values like -100 or 100
should result in a ban or exclusive selection of the relevant token.

As an example, you can pass {"50256": -100} to prevent the <|end-of-text|>
token from being generated.
*/
  logitBias?: Record<number, number>

  /**
Return the log probabilities of the tokens. Including logprobs will increase
the response size and can slow down response times. However, it can
be useful to understand better how the model is behaving.

Setting to true will return the log probabilities of the tokens that
were generated.

Setting to a number will return the log probabilities of the top n
tokens that were generated.
*/
  logprobs?: boolean | number

  /**
Whether to enable parallel function calling during tool use. Default to true.
   */
  parallelToolCalls?: boolean

  /**
A unique identifier representing your end-user, which can help OpenRouter to
monitor and detect abuse. Learn more.
*/
  user?: string

  /**
   * Web search plugin configuration for enabling web search capabilities
   */
  plugins?: Array<{
    id: 'web'
    /**
     * Maximum number of search results to include (default: 5)
     */
    max_results?: number
    /**
     * Custom search prompt to guide the search query
     */
    search_prompt?: string
  }>

  /**
   * Built-in web search options for models that support native web search
   */
  web_search_options?: {
    /**
     * Maximum number of search results to include
     */
    max_results?: number
    /**
     * Custom search prompt to guide the search query
     */
    search_prompt?: string
  }

  /**
   * Provider routing preferences to control request routing behavior
   */
  provider?: {
    /**
     * List of provider slugs to try in order (e.g. ["anthropic", "openai"])
     */
    order?: string[]
    /**
     * Whether to allow backup providers when primary is unavailable (default: true)
     */
    allow_fallbacks?: boolean
    /**
     * Only use providers that support all parameters in your request (default: false)
     */
    require_parameters?: boolean
    /**
     * Control whether to use providers that may store data
     */
    data_collection?: 'allow' | 'deny'
    /**
     * List of provider slugs to allow for this request
     */
    only?: string[]
    /**
     * List of provider slugs to skip for this request
     */
    ignore?: string[]
    /**
     * List of quantization levels to filter by (e.g. ["int4", "int8"])
     */
    quantizations?: Array<
      | 'int4'
      | 'int8'
      | 'fp4'
      | 'fp6'
      | 'fp8'
      | 'fp16'
      | 'bf16'
      | 'fp32'
      | 'unknown'
    >
    /**
     * Sort providers by price, throughput, or latency
     */
    sort?: 'price' | 'throughput' | 'latency'
    /**
     * Maximum pricing you want to pay for this request
     */
    max_price?: {
      prompt?: number | string
      completion?: number | string
      image?: number | string
      audio?: number | string
      request?: number | string
    }
  }
} & OpenRouterSharedSettings
